package com.kgis.map.common.util {
   import r1.deval.D;

   /**
    * 规则字符串解析类
    */
   public class Evals {
      public function Evals() {
      }

      /**
       * 将带有Level的字符串值计算出来并返回 用到的多了
       * @param strExpress
       * @param level
       * @return
       *
       */
      public static function getSizeByLevel(strExpress:String, level:int):Number {
         return D.evalToNumber(strExpress, {LEVEL: level});
      }

      /**判断表达式是true or false
       * @param fieldsMap object数组
       * @param expression 表达式
       */
      public static function evalToBoolean(fieldsMap:Object, expression:String):Boolean {
		 var result:Boolean=false;
		  try
		  {
			  result= D.evalToBoolean(expression, fieldsMap);
		  } 
		  catch(error:Error) 
		  {
			  trace("the rule filter syntax is error,the expression:"+expression);
			  return result;
		  }
		  return result;
      }

      /**求表达式的string值
       * @param fieldsMap object数组
       * @param expression 表达式
       * */
      public static function evalToString(fieldsMap:Object, expression:String):String {
		 var result:String="";
		  try
		  {
			  result= D.evalToString(expression, fieldsMap)
		  } 
		  catch(error:Error) 
		  {
			  trace("the rule filter syntax is error,the expression:"+expression);
			  return result;
		  }
		  return result;
      }

      /**求表达式的number值
       * @param fieldsMap object数组
       * @param expression 表达式
       * */
      public static function evalToNumber(fieldsMap:Object, expression:String):Number {
         return D.evalToNumber(expression, fieldsMap);
      }
   }
}